<!DOCTYPE html>
<html>
    <head>

    </head>
    <body>
        <script>
            function hello(){
                document.write("Hello world!<br />");
            }
            hello();
            //方式1
            function add(a,b){
                var result = a+b;
                return result;
            }
            document.write("3+5="+add(3,5)+"<br />");
            //方式2
            var add2=function(a,b){
                var result=a+b;
                return result;
            }
            document.write("3+5="+add2(3,5)+"<br />");

            //方式3
            var add3=new Function("a","b","return a+b");
            document.write("3+5="+add3(3,5)+"<br />");

            function day(year,moth,day){
                if(year%400==0||year%4==0&&year%100!=0){
                                var a=29;
                            }else{
                                var a=28;
                            }
                switch(moth){
                    case 1:return day;
                    case 2:return day+31;
                    case 3:return day+31+a;
                    case 4:return day+31+a+31;
                    case 5:return day+31+a+31+30;
                    case 6:return day+31+a+31+30+31;
                    case 7:return day+31+a+31+30+31+30;
                    case 8:return day+31+a+31+30+31+30+31;
                    case 9:return day+31+a+31+30+31+30+31+31;
                    case 10:return day+31+a+31+30+31+30+31+31+30;
                    case 11:return day+31+a+31+30+31+30+31+31+30+31;
                    case 12:return day+31+a+31+30+31+30+31+31+30+31+30;
                }
            }
            document.write("今天是今年的第"+day(2000,3,1)+"天");
        </script>
    </body>
</html>